package P4;

import java.net.*;
import java.util.Enumeration;

/**
 * 4.2编写列出本地机器所有网络接口的程序
 */
public class NetworkInterfaceLister {
    public static void main(String[] args) {
        try {
            Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
            while (networkInterfaces.hasMoreElements()) {
                NetworkInterface networkInterface = networkInterfaces.nextElement();
                System.out.println("Name: " + networkInterface.getName());
                System.out.println("Display Name: " + networkInterface.getDisplayName());
                System.out.println("Is Up: " + networkInterface.isUp());
                System.out.println("Is Virtual: " + networkInterface.isVirtual());
                System.out.println();
            }
        } catch (SocketException e) {
            e.printStackTrace();
        }
    }
}